<?php

namespace App\Admin\Controllers;

use App\Models\Wxuser;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;

class WxuserController extends Controller
{
    use HasResourceActions;

    /**
     * Index interface.
     *
     * @param Content $content
     * @return Content
     */
    public function index(Content $content)
    {
        return $content
            ->header('微信用户管理')
            ->description('')
            ->body($this->grid());
    }

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Wxuser);

        $grid->id('ID');
        $grid->disableCreateButton();
        $grid->disableExport();
        $grid->actions(function ($actions) {
            $actions->disableEdit();
            $actions->disableView();
        });
        $grid->avatarUrl()->image('http://media.weijingguanjia.com/',36,36);
        $grid->gender()->display(function($val){
            return $val==0?'男':'女';
        });
        $grid->columns('nickName','city','province','country','score');

        return $grid;
    }

}
